package com.xauto.pioneer.appuser.model;

import org.json.JSONObject;

import java.io.Serializable;

/**
 * 网点车辆
 * Created by Lemon on 27/02/2017.
 */
public class ParkingSiteCar extends BaseModel<ParkingSiteCar> {

    /** 当前项下标，用于判断是否有上一辆或下一辆*/
    public int index;
    /** 车辆ID*/
    public String car_id;
    /** 车辆编号*/
    public String car_no;
    /** 车牌号*/
    public String plate_no;
    /** 图片*/
    public Image car_image;
    /** 车辆续航里程*/
    public String car_endurance_mileage;
    /** 座位数*/
    public String seat_count;
    /** 车辆结构名称*/
    public String car_structure_name;
    /** 车辆系列名称*/
    public String car_series_name;
    /** 是否限号*/
    public Control_info is_control;
    /** 变速类型*/
    public String transmission_case_type_name;
    public BillingRuleInfo billingRuleInfo;
    public ParkingSiteCar() {
    }

    public class  BillingRuleInfo implements Serializable{
        public String billing_rule_name;
        public String billing_rule_title;
        public BillingRuleInfo parse(JSONObject jsonObject) {
            if(jsonObject != null) {
                billing_rule_name = jsonObject.optString("billing_rule_name");
                billing_rule_title = jsonObject.optString("billing_rule_title");
//                billing_rule_content_url = jsonObject.optString("billing_rule_content_url");
                return this;
            }
            return null;
        }

    }
    public class  Control_info implements Serializable{
        public String is_control;
    public Control_info parse(JSONObject jsonObject) {
        if(jsonObject != null) {
            is_control = jsonObject.optString("is_control");
            return this;
        }
        return null;
    }
}
    public ParkingSiteCar parse(int index,JSONObject jsonObject) {
        if(jsonObject != null) {
            this.index = index;
            car_id = jsonObject.optString("car_id");
            car_no = jsonObject.optString("car_no");
            plate_no = jsonObject.optString("plate_no");
            car_image = new Image().parse(jsonObject.optJSONObject("car_image"));
            car_endurance_mileage = jsonObject.optString("car_endurance_mileage");
            seat_count = jsonObject.optString("seat_count");
            car_structure_name = jsonObject.optString("car_structure_name");
            car_series_name = jsonObject.optString("car_series_name");
            transmission_case_type_name = jsonObject.optString("transmission_case_type_name");
            billingRuleInfo = new BillingRuleInfo().parse(jsonObject.optJSONObject("billing_rule_info"));
            is_control=new Control_info().parse(jsonObject.optJSONObject("control_info"));
            return this;
        }
        return null;
    }

    @Override
    public ParkingSiteCar parse(JSONObject jsonObject) {
        return null;
    }
}
